﻿@model NRemedy.WS_Incident
@{
    FormModel formModel = Html.GetFormModel();
    if (formModel == FormModel.Create)
    {
        ViewBag.Title = "创建事件";
    }
    else if (formModel == FormModel.Create)
    {
        ViewBag.Title = "搜索事件";
    }
    RouteValueDictionary create = new RouteValueDictionary();
    create.Add(NRemedyUIExtension.FormModelKey, "Create");
    int stageNumber = 0;

    //工作单
    NRemedyGrid<NRemedy.WS_Task> grid_WorkOrder = new NRemedyGrid<NRemedy.WS_Task>(
        new { style = "width:750px;height:400px", id = "table_workorder", title = "事件工作单" },
        new { pagination = true, fitColumns = true, singleSelect = true, toolbar = "#tb2" },
        null)
        .Column(m => m.RequestID, "ID", null, new { hidden = true })
        .Column(m => m.Sequence, "工序", null, new { sortable = true, width = 90 })
        .Column(m => m.AssigneeGroup, "负责团队", null, new { width = 90 })
        .Column(m => m.Assignee, "处理人员", null, new { width = 90 })
        .Column(m => m.Priority, "优先级", null, new { width = 90 })
        .Column(m => m.tms_status, "状态", null, new { width = 90 })
        .Column(m => m.TaskName, "主题", null, new { width = 90 })
        .Column(m => m.CreatedDateTime, "创建时间", null, new { width = 90 })
        .Qulification("EXTERNAL($1003$)");
    //日志
    NRemedyGrid<NRemedy.WS_Incident_Journal> incident_journal = new NRemedyGrid<NRemedy.WS_Incident_Journal>(
        new { style = "width:750px;height:400px", id = "table_worklog", title = "事件工作日志" },
        new { fitColumns = true, singleSelect = true, pagination = true, toolbar = "#tb" },
        null
        )
    .Column(p => p.RequestID, "ID", null, new { hidden = true })
    .Column(p => p.Category, "类型", null, new { width = 100 })
    .Column(p => p.CreateBy, "创建人", null, new { width = 100 })
    .Column(p => p.CreateTime, "创建时间", null, new { width = 150 })
    .Column(p => p.Subject, "主题", null, new { width = 100 })
    .Qulification("EXTERNAL($1002$)");
}
<script type="text/javascript">
    function edit(obj) {
        //修改日志
        if (obj.id == "btn_Detail") {
            var selectedRow = $('#table_worklog').datagrid('getSelected');
            if (selectedRow == null) {
                $.messager.alert("操作提示", "请先选择要修改的工作日志！");
                return false;
            }
            var id = selectedRow.f1;
            window.open('@Url.Action("JournalDetail", "Journal", null)' + '?RequestID=' + id + '&Operate=Edit');
        }
        //修改工作单
        if (obj.id == "btn_Detail2") {
            var selectedRow = $('#table_workorder').datagrid('getSelected');
            if (selectedRow == null) {
                $.messager.alert("操作提示", "请先选择要修改的工作单！");
                return false;
            }
            var id = selectedRow.f1;
            window.open('@Url.Action("TaskDetails", "Task", null)' + '?RequestID=' + id);
        }
    }
    function add(obj) {
        if ('@Model.IncidentNumber' == '') {
            $.messager.alert("操作提示", "无事件单号，请先保存事件！");
            return false;
        }
        //新增日志
        if (obj.id == "btn_Create") {

            window.open('@Url.Action("JournalDetail", "Journal", null)' + '?RequestID=' + '@Model.IncidentNumber' + '&Operate=Add');
        }
        //新增工作单
        if (obj.id == "btn_Create2") {
            window.open('@Url.Action("TaskDetails", "Task", null)' + '?ParentOBJID=' + '@Model.IncidentNumber' + '');

        }

    }

    $(function () {
        //为date类添加一个format方法
        //yyyy 年
        //MM 月
        //dd 日
        //hh 小时
        //mm 分
        //ss 秒
        //qq 季度
        //S  毫秒
        Date.prototype.formatDate = function (format) //author: meizz
        {
            var o = {
                "M+": this.getMonth() + 1, //month
                "d+": this.getDate(),    //day
                "h+": this.getHours(),   //hour
                "m+": this.getMinutes(), //minute
                "s+": this.getSeconds(), //second
                "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
                "S": this.getMilliseconds() //millisecond
            }
            if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
            (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o) if (new RegExp("(" + k + ")").test(format))
                format = format.replace(RegExp.$1,
              RegExp.$1.length == 1 ? o[k] :
                ("00" + o[k]).substr(("" + o[k]).length));
            return format;
        }
        $('#536870938').datetimebox({
            "showSeconds": true,
            formatter: function (date) {
                return date.formatDate("yyyy/MM/dd hh:mm:ss");
            }
        });

        $('#stage@(stageNumber)').bind('click', function (e) {
            e.preventDefault();
            $('#mm').menu('show', {
                left: e.pageX,
                top: e.pageY
            });
        });

        $('#536870937').combobox({
            hasDownArrow: false,
            url: '/Account/People',
            method: 'get',
            mode: 'remote',
            valueField: 'name',
            textField: 'name',
            panelHeight: 'auto',
            onSelect: function (record) {
                $('#536870920').val(record.phone);
                $('#536870950').val(record.email);
                $('#536870934').val(record.branch);
                $('#536870929').val(record.location);
                $('#536870928').val(record.dept);
                $('#536870927').val(record.seat);
            }
        });

    });

    function SelectCallBack(ta, record) {
        //选择事件小类后，通过查询将最长解决时间赋值
        $.get("/Incident/GetDuration", { Category: $("input[type='hidden'][name='Category']").val(), SubCategory: record.v })
                  .done(function (data) {
                      $("input[name='EstimatedEffortMinute']").val(data);
                  })
    }

    $(document).ready(function () {

        $("#Name").autocomplete({
            source: "/Incident/GetNameListByName/" + $("#Name").val(), // 自动填充的备选数据，注1  
            position: { my: "left top", at: "left bottom" }, // 下拉列表相对于文本框的位置，注2  
            minLength: 1, // 自动填充被激活前需要输入的最小字符数，默认为1  
            delay: 300, // 停止输入到自动填充被激活的延迟时间，默认为300  
            autoFocus: false, // 是否自动聚焦于下拉列表第一项，默认为false  
            appendTo: "body", // 自动填充的下拉列表放到哪个元素内部，注3  
            disabled: false, // 是否禁用自动填充，默认为false  
            create: function (event, ui) { }, // 自动填充被创建时被触发  
            search: function (event, ui) { }, // 在达到最小输入字符数并且延迟时间结束之后，自动填充数据请求开始之前被触发  
            open: function (event, ui) { }, // 下拉列表打开时被触发  
            focus: function (event, ui) { }, // 下拉列表项被聚焦时触发，ui.item对应被聚焦的列表项  
            select: function (event, ui) { }, // 下拉列表项被选择时触发，ui.item对应被选择的列表项  
            close: function (event, ui) { }, // 下拉列表隐藏时被触发  
            change: function (event, ui) {
                $.get("/Incident/GetPeopleInfoByName", { Name: $("#Name").val() })
            .done(function (data) {
                $("#Phone").val(data.Phone);
                $("#Email").val(data.Email);
                $("#BranchOffice").val(data.BranchOffice);
                $("#Location").val(data.Location);
                $("#Department").val(data.Department);
                $("#Seat").val(data.Seat);
            })
            } // 文本域的值发生改变时被触发，ui.item对应新的被选择的列表项  
        });
    })

</script>
<style type="text/css">
    div.stage
    {
        margin-left: 2px;
        padding-left: 5px;
        height: 45px;
        line-height: 45px;
        width: 145px;
        float: left;
        font-weight: bold;
        color: #fff;
    }
</style>
<div class="easyui-layout" id="wrap" style="height: 700px;">
    @using (Html.BeginForm())
    {
        
        <div data-options="region:'west',split:false" id="body_left" style="width: 250px;
            border-right-style: none;">
            <div title="事件" class="easyui-panel" border="false" style="height: 359px;">
                <table class="left-input-layout">
                    <tr>
                        <td class="label">
                            ID
                        </td>
                        <td>
                            @if (formModel == FormModel.Search)
                            {
                                @Html.InputFor(m => m.IncidentNumber)
                            }
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            状态
                        </td>
                        <td>
                            @Html.MenuFor(m => m.IncidentStatus, new RemedyMVC.Menu.Menu_Incident_Status(), null, new { disabled = true }, false)
                        </td>
                    </tr>
                </table>
            </div>
            <div title="快速操作" class="easyui-panel" border="false" style="height: 300px;">
            </div>
        </div>  
        <div data-options="region:'center'" id="body_center">
            <div class="easyui-layout" data-options="fit:true">
                <div id="control-bar" data-options="region:'north',border:false" style="height: 55px;
                    overflow: hidden;">
                    <div style="margin: 5px 50px 5px 200px;">
                        <div id="stage0" class="stage" style="background-color:@(stageNumber == 0 ? "#8BBA30;cursor:pointer" : "#04ACAD")">
                            标识和记录</div>
                        <div id="stage1" class="stage" style="background-color:@(stageNumber == 1 ? "#8BBA30;cursor:pointer" : "#04ACAD")">
                            调查与诊断</div>
                        <div id="stage2" class="stage" style="background-color:@(stageNumber == 2 ? "#8BBA30;cursor:pointer" : "#04ACAD")">
                            解决和恢复</div>
                        <div id="stage3" class="stage" style="background-color:@(stageNumber == 3 ? "#8BBA30;cursor:pointer" : "#04ACAD")">
                            已解决</div>
                        <div id="stage4" class="stage" style="background-color:@(stageNumber == 4 ? "#8BBA30;cursor:pointer" : "#04ACAD")">
                            已关闭</div>
                        <div style="clear: both;">
                        </div>
                    </div>
                    <div id="mm" class="easyui-menu" minwidth="50">
                        @if (formModel == FormModel.Create)
                        {
                            <div>
                                <a id="btn_submit" name="@RemedyMVC.Controllers.IncidentController.Incident_Action.Assigned" href="#" 
                    class="easyui-linkbutton commit-change-mod" 
                    action="@Url.Action("Form", create)" 
                    data-options="plain:true">分派</a>
                            </div>                      
                            <div>
                                <a id="btn_resolved" name="@RemedyMVC.Controllers.IncidentController.Incident_Action.Resolve" href="#" 
                    class="easyui-linkbutton commit-change-mod" 
                    action="@Url.Action("Form", create)" 
                    data-options="plain:true">解决</a>
                            </div>
                        }
                    </div>
                </div>
                <div data-options="region:'west',border:true,split:false" style="width: 275px; height: 300px;
                    border-bottom-style: none; border-left-style: none;">
                    <table class="left-input-layout" style="border: 1px solid #003366; margin-top: 5px;">
                        <tr>
                            <td>
                                <label style="font-weight: bolder;">
                                    客户信息</label>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    姓名:</label>
                            </td>
                            <td>
                                @Html.InputFor(m => m.FullName)
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    电话/分机:</label>
                            </td>
                            <td>
                                @Html.InputFor(m => m.Phone)
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    电邮:</label>
                            </td>
                            <td>
                                @Html.InputFor(m => m.Email)
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    分公司:</label>
                            </td>
                            <td>
                                @Html.InputFor(m => m.BranchOffice)
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    地点:</label>
                            </td>
                            <td>
                                @Html.InputFor(m => m.Location)
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    部门:</label>
                            </td>
                            <td>
                                @Html.InputFor(m => m.Department)
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    座位:</label>
                            </td>
                            <td>
                                @Html.InputFor(m => m.Seat)
                            </td>
                        </tr>
                    </table>
                    <table class="left-input-layout" style="border: 1px solid #003366; width: 247px;">
                        
                        <tr>
                            <td>
                                <label>
                                    事件来源:</label>
                            </td>
                            <td>
                                @Html.MenuFor(m => m.Source, new RemedyMVC.Menu.Menu_Incident_Source())
                            </td>
                        </tr>
                        <tr>
                            <td style="width:60px;">
                                <label>
                                    事件类型:</label>
                            </td>
                            <td>
                                @Html.MenuFor(m => m.TypeOfIncident, new RemedyMVC.Menu.Menu_Incident_Type())
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    事件大类:</label>
                            </td>
                            <td>
                                @Html.MenuFor(m => m.Category, new RemedyMVC.Menu.Menu_Incident_Category())
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    事件小类:</label>
                            </td>
                            <td>
                                @*@Html.MenuFor(m => m.SubCategory, new RemedyMVC.Menu.Menu_Incident_SubCategory(), new { onSelect = "SelectCallBack" }, null)*@
                                @Html.MenuFor(m => m.SubCategory, new RemedyMVC.Menu.Menu_Incident_SubCategory(), null, null)
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label>
                                    症状类型:</label>
                            </td>
                            <td>
                                @Html.MenuFor(m => m.SymptomType, new RemedyMVC.Menu.Menu_Incident_SymptomType())
                            </td>
                        </tr>
                        <tr>
                            <td>
                                影响度：
                            </td>
                            <td>
                                @Html.MenuFor(m => m.Impact, new RemedyMVC.Menu.Menu_Incident_Impact())
                            </td>
                        </tr>
                        <tr>
                            <td>
                                紧迫度：
                            </td>
                            <td>
                                @Html.MenuFor(m => m.Urgency, new RemedyMVC.Menu.Menu_Incident_Urgency())
                            </td>
                        </tr>
                        <tr>
                            <td>
                                优先级：
                            </td>
                            <td>
                                @Html.MenuFor(m => m.Priority, new RemedyMVC.Menu.Menu_Incident_Priority())
                            </td>
                        </tr>
                    </table>
                    <table class="left-input-layout">
                        <tr>
                            <td>
                                @if (formModel == FormModel.Create)
                                {
                                    <a id="btn_save" name="@RemedyMVC.Controllers.IncidentController.Incident_Action.Logged"
                                href="#" class="easyui-linkbutton commit-change-mod" 
                                action="@Url.Action("Form", create)"  
                                data-options="iconCls:'icon-save'">保存</a>
                                }
                            </td>
                        </tr>
                    </table>
                </div>
                <div data-options="region:'center',border:false">
                    <div class="easyui-tabs" style="height: 600px;" border="false">
                        <div title="事件详情" style="padding: 10px">
                            <table class="left-input-layout">
                                <tr>
                                    <td class="top-label">
                                        主题
                                    </td>
                                    <td>
                                        @Html.TextAreaFor(m => m.Subject, new { style = "width: 300px" }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        症状
                                    </td>
                                    <td>
                                        @Html.TextAreaFor(m => m.Symptom, new { style = "width: 300px" }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        负责团队
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.OwnerTeam, new RemedyMVC.Menu.Menu_Incident_OwnerTeam())
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        处理人员
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.Owner, new RemedyMVC.Menu.Menu_Incident_Owner())
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        最晚解决期限
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.TargetResolutionTime, new { style = "width: 300px" })
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        最长解决时长
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.EstimatedEffortMinute, new { style = "width: 300px" })
                                    </td>
                                </tr>
                                @*<tr>
                                    <td class="top-label">
                                        CI项计数
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.CICount, new { style = "width: 300px" }, false)
                                    </td>
                                </tr>*@
                            </table>
                        </div>
                        <div title="解决方案" style="overflow: auto; padding: 20px;">
                            <table class="left-input-layout">
                                <tr>
                                    <td class="top-label">
                                        解决方案大类
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.ActualCategory, new RemedyMVC.Menu.Menu_Incident_ResolutionCategory())
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        解决方案小类
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.ActualSubCategory, new RemedyMVC.Menu.Menu_Incident_ResolutionSubCategory())
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        发生原因
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.CauseCode, new RemedyMVC.Menu.Menu_Incident_ResolutionCauseCode())
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        解决途径
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.WayOfResolution, new RemedyMVC.Menu.Menu_Incident_WayOfResolution())
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        解决代码
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.ResolveCode, new RemedyMVC.Menu.Menu_Incident_ResolveCode())
                                        @Html.InputFor(m => m.IsWorkAround, new { type = "checkbox" })
                                        <label>
                                            权益措施</label>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        解决方案
                                    </td>
                                    <td>
                                        @Html.TextAreaFor(m => m.Resolution, new { style = "width: 230px;height:100px" }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        变更编号
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.AppChangeNumber, null)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        操作类型
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.AppTypeOfOperation, new RemedyMVC.Menu.Menu_Incident_AppTypeOfOperation())
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        产生原因
                                    </td>
                                    <td>
                                        @Html.MenuFor(m => m.AppTypeOfChange, new RemedyMVC.Menu.Menu_Incident_AppTypeOfChange())
                                    </td>
                                </tr>
                            </table>
                        </div>
                        @*<div title="解决过程" style="padding: 20px; display: none;">
                            <table class="left-input-layout">
                                <tr>
                                    <td class="top-label">
                                        解决方案大类
                                    </td>
                                    <td>
                                        @* @Html.MenuFor(m => m.ActualCategory, new RemedyMVC.Menu.Menu_Incident_ResolutionCategory())
                                    </td>
                                </tr>
                                <tr>
                                    <td class="top-label">
                                        解决方案小类
                                    </td>
                                    <td>
                                        Html.MenuFor(m => m.ActualSubCategory, new RemedyMVC.Menu.Menu_Incident_ResolutionSubCategory())
                                    </td>
                                </tr>
                            </table>
                        </div>*@
                        <div title="工作单" style="padding: 20px;">
                            <div id="tb2" style="height: auto">
                                <a id="btn_Create2" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add',disabled:true"
                                    onclick="javascript:add(this)">创建</a> <a id="btn_Detail2" class="easyui-linkbutton"
                                        data-options="plain:true,iconCls:'icon-search',disabled:true" onclick="javascript:edit(this)">
                                        查看</a>
                            </div>
                            @grid_WorkOrder.GetHtml()
                            <input type="text" id="1003" value="@(string.Format("('536870914' = \"{0}\")", Model.IncidentNumber))" style="display: none;" />
                        </div>
                        <div title="日志" style="padding: 20px;">
                            <div id="tb" style="height: auto">
                                <a id="btn_Create" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add',disabled:true"
                                    onclick="javascript:add(this)">创建</a> <a id="btn_Detail" class="easyui-linkbutton"
                                        data-options="plain:true,iconCls:'icon-search',disabled:true" onclick="javascript:edit(this)">
                                        查看</a>
                            </div>
                            @incident_journal.GetHtml()
                            <input type="text" value="@(string.Format("('536870934' = \"{0}\")", Model.IncidentNumber))" id="1002" style="display: none;" />
                        </div>
                        <div title="附件" style="padding: 20px; display: none;">
                            tab3
                        </div>
                        <div title="相关请求" style="padding: 20px; display: none;">
                            tab3
                        </div>
                        <div title="相关配置" style="padding: 20px; display: none;">
                            tab3
                        </div>
                        <div title="审计日志" style="padding: 20px; display: none;">
                            tab3
                        </div>
                       @* <div title="操作单" style="padding: 20px; display: none;">
                            tab3
                        </div>*@
                        <div title="日期/人员信息" style="padding: 10px">
                            <table class="left-input-layout">
                                <tr>
                                    <td class="label">
                                        事件创建人
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.CreatedBy, new { disabled = true }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        事件创建时间
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.CreatedDateTime, new { disabled = true }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        事件修改人
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.LastModBy, new { disabled = true }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        事件更改时间
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.LastModDateTime, new { disabled = true }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        事件解决人
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.ResolvedBy, new { disabled = true }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        事件解决时间
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.ResolvedDate, new { disabled = true }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        事件关闭人
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.CloseBy, new { disabled = true }, false)
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label">
                                        事件关闭时间
                                    </td>
                                    <td>
                                        @Html.InputFor(m => m.ClosedDateTime, new { disabled = true }, false)
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>  
    }
</div>
